----------------------------------------------------------------------------------------------------------------------------------
--[[

    near danger hook

    inst.IsNearDanger

]]--
----------------------------------------------------------------------------------------------------------------------------------
local hutao_com_near_danger = Class(function(self, inst)
    self.inst = inst

    self.danger_tags = {}

    inst:DoTaskInTime(1,function()

        local old_IsNearDanger = inst.IsNearDanger

        inst.IsNearDanger = function(inst,...)
            local origin_ret = old_IsNearDanger(inst,...)
            if not origin_ret then
                for tag,flag in pairs(self.danger_tags) do
                    if flag then
                        origin_ret = true
                        break
                    end
                end
            end
            return origin_ret
        end
        
    end)

end,
nil,
{

})
------------------------------------------------------------------------------------------------------------------------------
--
    function hutao_com_near_danger:AddDanger(tag)
        self.danger_tags[tag] = true
    end
    function hutao_com_near_danger:RemoveDanger(tag)
        self.danger_tags[tag] = false
    end
------------------------------------------------------------------------------------------------------------------------------
--
    function hutao_com_near_danger:IsNearDanger()
        return self.inst:IsNearDanger()
    end
------------------------------------------------------------------------------------------------------------------------------
return hutao_com_near_danger







